#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	int n;scanf("%d",&n);
	std::vector<int> v(n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&v[i]);
	}
	sort(v.begin(),v.end());
	int ansindex=-1;
	for (int i = 0; i < n; ++i)
	{
		int smallercnt=i;
		while(v[i+1]==v[i])i++;
		int biggercnt=n-i-1;
		if(smallercnt==biggercnt){
			ansindex=i;
			break;
		}
	}
	if(ansindex>=0)
		printf("%d\n", v[ansindex]);
	else{
		printf("-1\n");
	}

	return 0;
}